<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>location对象</title>
</head>
<body>

    <input type="button" id="btn" value="刷新">
    <input type="button" id="goBD" value="去百度">

<script>
    //reload方法，定义一个按钮，点击按钮，刷新当前页面
    //1.获取按钮
    var btn = document.getElementById("btn");
    //2.绑定单击事件
    btn.onclick = function(){
        //3.刷新页面
        location.reload();
    }

    //设置href
    var href = location.href
    alert(href);

    //点击按钮，去访问www.baidu.com
    //1.获取按钮
    var btn1 = document.getElementById("goBD");
    //2.绑定单击事件
    btn1.onclick = function () {
        //3.去访问www.baidu.com
        location.href = "http://www.baidu.com"
    }

</script>
</body>
</html>